package org.essilab.analyzer.analyzer;

import java.util.HashMap;


/**
 * This class is a Term wrapper.
 * It provide additionnal statistics about the original Term 
 * such as his number of occurences (in the given context) and an heuristic weight.
 * 
 * @author Mohamed-Amine Chouchene, Ahcène Idinarere, Vincent Nock, Alain
 * Janin-Manificat
 * @see Term 
 */
public class AnalyzedTerm implements Cloneable {

	/**
	 * Real informations of term
	 */
	private Term term;
	
    /**
     * Occurrences of the term in analyzed text Equals to 0 if AnalyzedTerm
     * describes a relational Term
     */
    private int occurences;
    /**
     * Current weight of the analyzed term
     */
    private double weight;
	
	
	private HashMap<AnalyzedTerm, Double> ancestors;
	
	
	/**
     * Contructor, set the original Term and init attributes.
     * @param t     Term - The referenced Term of this AnalyzedTerm.
     * @see Term
     */
	public AnalyzedTerm(Term t) {
		this.term = t;
		this.occurences = 0;
//		this.rootTerm = null;
		this.weight = 0;
		this.ancestors = new HashMap<>();
	}
	
	public AnalyzedTerm clone()  {
		AnalyzedTerm at = new AnalyzedTerm(this.term);
		at.setOccurences(this.occurences);
		at.setWeight(this.weight);
		at.setAncestors(this.ancestors);
		
		return at;
		
	}

    /**
     * Add a value to current weight.
     * @param weight    float - value to add to current weight.
     */	
	public void addWeight(double weight) {
		this.weight += weight;
	}
	
	/////////////////////////////////////////////
	// GETTERS and SETTERS
	/////////////////////////////////////////////
	
//	public AnalyzedTerm getRootTerm() {
//		return rootTerm;
//	}
//
//	public void setRootTerm(AnalyzedTerm rootTerm) {
//		this.rootTerm = rootTerm;
//	}

	public Term getTerm() {
		return term;
	}

	public void setTerm(Term term) {
		this.term = term;
	}

	public int getOccurences() {
		return occurences;
	}

	public void setOccurences(int occurences) {
		this.occurences = occurences;
	}

	public double getWeight() {
		return weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	public HashMap<AnalyzedTerm, Double> getAncestors() {
		return ancestors;
	}

	public void setAncestors(HashMap<AnalyzedTerm, Double> ancestors) {
		this.ancestors = ancestors;
	}

	
}
